<?php

/**
 * Entry point for communities applications
 *
 * @copyright Sebastien Delcampe
 * @license Please, don't read or copy
 *
 * @author Delcampe Dev Team
 *
 *
 * @version 1.0
 * @package Communities
 *
 */
error_reporting(E_ALL|E_STRICT);
ini_set('display_errors',true); // set this to 0 on live version

date_default_timezone_set('Europe/Brussels');

set_include_path('.' . PATH_SEPARATOR . '../library' .
PATH_SEPARATOR . get_include_path());

include('Zend/Loader.php');
include('Zend/Loader/Autoloader.php');
require_once ('Zend/Json.php');

$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('Lion_');
Zend_Session::start();

$staging = 'anuradha';

$config = new Zend_Config_Ini('../application/config/db_config.ini', $staging);
$registry = Zend_Registry::getInstance();
$db = Zend_Db::factory($config->db);
$registry->set('config',$config);
$registry->set('db',$db);

Zend_Db_Table::setDefaultAdapter($db);

/*try {
  Delcampe_Locale::setLangs($config->supLanguages);
  $locale = new Delcampe_Locale('browser');
} catch (Zend_Locale_Exception $e) {
  $locale = new Zend_Locale($config->application['defaultLang']);
}
$registry->set('locale',$locale);*/

$view = new Zend_View;
$view->addHelperPath('../library/View/Helper','Lion_View_Helper');
$view->addHelperPath('../library/ZendX/JQuery/View/Helper','ZendX_JQuery_View_Helper');
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view);
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);

//$registry->set('view',$view);

$layout = array(
            'layout'     => 'layout',
            'layoutPath' => $config->resources->layout->layoutPath
);

Zend_Layout::startMvc($layout);

$data = array(
  'dbAdapter'  => 'delcampe1',
  'tableName'  => 'td_labels',
  'joinTable'  => 'td_labels_key',
  'localeField'=> 'language',
  'keyField' 	 => 'id',
  'valueField' => 'contents',
  'joinField'  => 'keyText',
);

$options = array();

/*try {
  $adapter = new Zend_Translate('Delcampe_Translate_Adapter_Db', $data, $locale, $options);
  Zend_Registry::set('translate',$adapter);  
} catch (Zend_Translate_Exception $e) {
  echo $e->getMessage();
}*/

$frontcontroller = Zend_Controller_Front::getInstance();
$frontcontroller->throwExceptions(true);
$frontcontroller->setControllerDirectory(array(
	'default'		=>'../application/default/controllers',
	'admin'			=>'../application/admin/controllers'	
));

$frontcontroller->dispatch();
